package com.luoy.util;

import com.luoy.enums.ResultEnum;
import org.springframework.beans.factory.annotation.Value;

/**
 * 返回信息工具类
 *
 * @author LUOY
 * @create 2018-05-22-上午9:58
 */

public class ResultVOUtil {

    @Value("${dev}")
    private static boolean dev;

    /**
     * 返回成功,并设置返回数据
     *
     * @param object
     * @return
     */
    public static ResultVO success(Object object) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(ResultEnum.SUCCESS.getCode());
        resultVO.setMsg(ResultEnum.SUCCESS.getMessage());
        resultVO.setData(object);
        return resultVO;
    }

    /**
     * 返回成功
     *
     * @return
     */
    public static ResultVO success() {
        return success(null);
    }

    /**
     * 返回失败,设置错误码和错误信息
     *
     * @param code
     * @param msg
     * @return
     */
    public static ResultVO error(Integer code, String msg) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(code);
        resultVO.setMsg(msg);
        return resultVO;
    }
}
